Skip to content

Comments

feat: add p2p-proxy subcommand to tempo binary#2780

Open
mattsse wants to merge 2 commits intomainfrom
feat/p2p-proxy-subcommand
Open

feat: add p2p-proxy subcommand to tempo binary#2780
mattsse wants to merge 2 commits intomainfrom
feat/p2p-proxy-subcommand

Conversation

@mattsse
Copy link
Contributor

@mattsse mattsse commented Feb 19, 2026

Summary

Add a new tempo p2p-proxy subcommand that runs a proxy P2P node serving cached block data fetched from an RPC endpoint. This replaces the previous sidecar-based implementation by integrating directly into the main tempo binary.

Features

  • Block caching: Caches up to 1 day of blocks (172,800 at 500ms block time) with LRU eviction
  • Request serving: Handles GetBlockHeaders and GetBlockBodies with automatic RPC fallback for cache misses
  • Transport flexibility: Supports HTTP and WebSocket RPC transports via connect()
  • CLI args: --rpc-url, --chain, --port, --discovery-port, --max-inbound, --max-concurrent-inbound
  • Monitoring: Periodic stats logging (peer count, headers/bodies served every 30s)
  • Robustness: Always responds to peers even on internal failures (never drops response channel)
  • Inbound-only: Zero outbound connections, tx gossip disabled

Usage

tempo p2p-proxy --rpc-url https://rpc.moderato.tempo.xyz --chain moderato
tempo p2p-proxy --rpc-url ws://localhost:8546 --port 9999 --max-inbound 50

Tests

  • CLI parser tests for default args, all args, and missing required args
  • E2E tests against live Moderato RPC (headers, bodies, hash-based fetch)

Add a new `tempo p2p-proxy` subcommand that runs a proxy P2P node
serving cached block data fetched from an RPC endpoint.

Features:
- Caches up to 1 day of blocks (172,800 at 500ms block time)
- Serves GetBlockHeaders and GetBlockBodies requests with RPC fallback
- Supports HTTP and WebSocket RPC transports via connect()
- Configurable max inbound peers (default 100), listen port, discovery port
- Periodic stats logging (peer count, headers/bodies served)
- Empty responses for GetPooledTransactions, receipts, and other requests
- Inbound-only connections (zero outbound)
- Always responds to peers even on internal failures

Amp-Thread-ID: https://ampcode.com/threads/T-019c7645-fde2-734e-bfd8-30028c50faf9
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant